package fr.cephb.joperon.core.entities;
import javax.xml.bind.annotation.XmlTransient;

import com.sleepycat.db.DatabaseEntry;
import com.sleepycat.db.DatabaseException;
import fr.cephb.joperon.core.entities.base.BaseGtypes;


/**
 * Gtypes
 * Description: Genotype alleles
 */
public class Gtypes
	extends BaseGtypes
	{
	/**
     *
     * Constructor
     *
     */
	public Gtypes()
		{
		super();
		}


        /**
         *
         * Copy Constructor
         *
         */
		public Gtypes(BaseGtypes cp)
			{
			super(cp);
			}
		
		/**
		 * constructor from a database entry
		 *
		 */
		public Gtypes(DatabaseEntry entry) throws DatabaseException
			{
			super(entry);
			}
		
		
        /**
         *
         * clone
         *
         */
		public Object clone()
			{
			return new Gtypes(this);
			}
		
		
		@XmlTransient
		public String getAlleles()
			{
			return gtype_decode(getCode());
			}
		
		
		public static String gtype_decode(short code)
			{
			switch(code)
				{
				case   1: return "AA"; 
				case   2: return "CC"; 
				case   3: return "GG"; 
				case   4: return "TT"; 
				case   5: return "AC"; 
				case   6: return "AG"; 
				case   7: return "AT"; 
				case   8: return "CG"; 
				case   9: return "CT"; 
				case  10: return "GT"; 
				case  15: return "CA"; 
				case  16: return "GA"; 
				case  17: return "TA"; 
				case  18: return "GC"; 
				case  19: return "TC"; 
				case  20: return "TG"; 
				case  21: return "00"; 
				case  22: return "AN"; 
				case  23: return "CN"; 
				case  24: return "GN"; 
				case  25: return "TN"; 
				case  26: return "N"; 
				case  27: return "A"; 
				case  28: return "C"; 
				case  29: return "G"; 
				case  30: return "T"; 
				case  31: return "0"; 
				default : return "NN";
				}
				}
	
		}

